package com.spzx.cloud.order.service.impl;

import com.spzx.cloud.entity.Order;
import com.spzx.cloud.entity.User;
import com.spzx.cloud.feign.api.UserFeignClient;
import com.spzx.cloud.order.mapper.OrderMapper;
import com.spzx.cloud.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OrderServiceImpl implements OrderService {

    @Autowired
    private OrderMapper orderMapper;

    @Autowired
    private UserFeignClient userFeignClient;

    @Override
    public Order findOrderByOrderId(Long orderId) {
        // 查询订单信息
        Order order = this.orderMapper.findOrderByOrderId(orderId);

        User user = userFeignClient.queryById(order.getUserId());
        order.setUser(user);

        return order;
    }

}